home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
asm68k.arc
/
INHEX.FOR
< prev
next >
Wrap
Text File
|
1985-11-09
|
3KB
|
111 lines
c
CC Written by:
c Julian Henry
c TriSoft
c 4102 Avenue G
c Austin, Texas 78751
c
c
c INHEX converts ASM68K object files to INTEL.HEX format
c
c
implicit integer(a-z)
integer*2 temval,cc
byte tval(2),bval(19),chksum(2)
character*36 fname
character*1 buf(80),space,zero
equivalence (cc,chksum(1)),(temval,tval(1))
data space/' '/
data zero/'0'/
1000 type 1010
1010 format(' Input file spec: ',$)
accept 1005,fname
1005 format(a36)
open(unit=7,name=fname,err=1015,type='old',
* carriagecontrol='list',readonly,dispose='save')
go to 1020
1015 type 1017
1017 format(//,' **ERROR** Bad file spec, try again.')
go to 1000
1020 type 1030
1030 format(' Output file spec: ',$)
accept 1005,fname
open(unit=8,name=fname,err=1035,type='new',
* carriagecontrol='list',dispose='save')
go to 1040
1035 type 1017
go to 1020
1040 open(unit=9,name='INHEX.ERR',type='new',
* carriagecontrol='list',dispose='save')
errcnt=0
open(unit=10,name='temp.dat',type='new',dispose='delete')
c
c read input record
c
10 read(7,20,end=900)buf
20 format(80a1)
c
c crack buf into byte values
c
decode(80,30,buf)bval
30 format(1x,3z2,8(1x,2z2))
c type 30,bval
c
c check if address is outside 64K range
c
if(bval(1).eq.0)go to 50
write(9,20)buf
errcnt=errcnt+1
go to 10
c
c compute byte count
c
50 bytcnt=0
do 55 i=9,44,5
if(buf(i).eq.space)go to 60
bytcnt=bytcnt+2
55 continue
c
c compute checksum
c
60 cc=0
do 65 i=2,19
tval(2)=0
tval(1)=bval(i)
cc=cc+temval
65 continue
cc=cc+bytcnt
c
c output record
c
write(10,70)bytcnt,(bval(i),i=2,bytcnt+3),-chksum(1)
70 format(':',3z2,'00',17z2)
go to 10
c
c EOF, output EOF card
c
900 rewind 10
901 read(10,20,end=909)buf
do 902 i=80,1,-1
if(buf(i).ne.space)go to 903
902 continue
903 do 904 j=i,1,-1
if(buf(j).eq.space)buf(j)=zero
904 continue
write(8,20)(buf(j),j=1,i)
go to 901
909 write(8,910)
910 format(':0000000000')
if(errcnt.eq.0)go to 920
close(unit=9,dispose='save')
type 925
925 format(//,' Errors detected, see INHEX.ERR')
go to 930
920 close(unit=9,dispose='delete')
type 928
928 format(//,' No Errors detected, conversion completed.')
930 close(unit=7,dispose='save')
close(unit=8,dispose='save')
close(unit=10,dispose='delete')
end